import { Dispatch, SetStateAction, useState, useEffect } from 'react';

export function useFormLocalState<T>(
  value: T,
): [T, Dispatch<SetStateAction<T>>] {
  const [formLocalState, setFormLocalState] = useState<T>(value);

  useEffect(() => {
    setFormLocalState(value);
  }, [value]);

  return [formLocalState, setFormLocalState];
}
